home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / System Extras Headers / AOCE Headers / DigitalSignature.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-20  |  9.1 KB  |  286 lines  |  [TEXT/MMCC]

  1. /*
  2.     File:        DigitalSignature.h
  3.  
  4.     Copyright:    © 1984-1993 by Apple Computer, Inc., all rights reserved.
  5.  
  6.     WARNING
  7.     This file was auto generated by the interfacer tool. Modifications
  8.     must be made to the master file.
  9.  
  10. */
  11.  
  12. #ifndef __DIGITALSIGNATURE__
  13. #define __DIGITALSIGNATURE__
  14.  
  15. #ifndef __FILES__
  16. #include <Files.h>
  17. /*    #include <Types.h>                                            */
  18. /*        #include <ConditionalMacros.h>                            */
  19. /*        #include <MixedMode.h>                                    */
  20. /*            #include <Traps.h>                                    */
  21. /*    #include <OSUtils.h>                                        */
  22. /*    #include <SegLoad.h>                                        */
  23. #endif
  24.  
  25. #ifndef __MEMORY__
  26. #include <Memory.h>
  27. #endif
  28.  
  29. #ifndef __TYPES__
  30. #endif
  31.  
  32. /* —————————————————————————— MACROS AND TRAP SELECTORS —————————————————————————— */
  33. #define __DigitalSignature(count, selector) = { 0x203C, count, selector, 0xAA5D}
  34.  
  35. #define kSIGNewContext 1900
  36.  
  37. #define kSIGDisposeContext 1901
  38.  
  39. #define kSIGSignPrepare 1902
  40.  
  41. #define kSIGSign 1903
  42.  
  43. #define kSIGVerifyPrepare 1904
  44.  
  45. #define kSIGVerify 1905
  46.  
  47. #define kSIGDigestPrepare 1906
  48.  
  49. #define kSIGDigest 1907
  50.  
  51. #define kSIGProcessData 1908
  52.  
  53. #define kSIGShowSigner 1909
  54.  
  55. #define kSIGGetSignerInfo 1910
  56.  
  57. #define kSIGGetCertInfo 1911
  58.  
  59. #define kSIGGetCertNameAttributes 1912
  60.  
  61. #define kSIGGetCertIssuerNameAttributes 1913
  62.  
  63. #define kSIGFileIsSigned 2500
  64.  
  65. #define kSIGSignFile 2501
  66.  
  67. #define kSIGVerifyFile 2502
  68.  
  69. /* values of SIGNameAttributeType */
  70. enum  {
  71.     kSIGCountryCode,
  72.     kSIGOrganization,
  73.     kSIGStreetAddress,
  74.     kSIGState,
  75.     kSIGLocality,
  76.     kSIGCommonName,
  77.     kSIGTitle,
  78.     kSIGOrganizationUnit,
  79.     kSIGPostalCode
  80. };
  81.  
  82. typedef unsigned short SIGNameAttributeType;
  83.  
  84. /* 
  85. Certificate status codes returned in SIGCertInfo or SIGSignerInfo from
  86. either SIGGetCertInfo or SIGGetSignerInfo respectively. kSIGValid means that
  87. the certificate is currently valid. kSIGPending means the certificate is
  88. currently not valid - but will be.  kSIGExpired means the certificate has
  89. expired. A time is always associated with a SIGCertStatus.  In each case the
  90. time has a specific interpretation.  When the status is kSIGValid the time is
  91. when the certificate will expire. When the status is kSIGPending the time is
  92. when the certificate will become valid. When the status is kSIGExpired the time
  93. is when the certificate expired. In the SIGCertInfo structure, the startDate
  94. and endDate fields hold the appropriate date information.  In the SIGSignerInfo
  95. structure, this information is provided in the certSetStatusTime field. In the
  96. SIGSignerInfo struct, the status time is actually represented by the SIGSignatureStatus
  97. field which can contain any of the types below. NOTE: The only time you will get 
  98. a kSIGInvalid status is when it pertains to a SIGSignatureStatus field and only when
  99. you get a signature that was created after the certificates expiration date, something
  100. we are not allowing on the Mac but that may not be restricted on other platforms. Also, 
  101. it will not be possible to get a kSIGPending value for SIGSignatureStatus on the Mac but
  102. possibly allowed by other platforms.
  103. */
  104.  
  105. /* Values for SIGCertStatus or SIGSignatureStatus */
  106. enum  {
  107.     kSIGValid,
  108.     kSIGPending,
  109.     kSIGExpired,
  110.     kSIGInvalid
  111. };
  112.  
  113. typedef unsigned short SIGCertStatus;
  114.  
  115. typedef unsigned short SIGSignatureStatus;
  116.  
  117. /* Gestalt selector code - returns toolbox version in low-order word */
  118. #define gestaltDigitalSignatureVersion 'dsig'
  119.  
  120. /* Number of bytes needed for a digest record when using SIGDigest */
  121. #define kSIGDigestSize 16
  122.  
  123. typedef Byte SIGDigestData[16], *SIGDigestDataPtr;
  124.  
  125. #if defined(powerc) || defined (__powerc)
  126. #pragma options align=mac68k
  127. #endif
  128. struct SIGCertInfo {
  129.     unsigned long                startDate;
  130.     unsigned long                endDate;
  131.     SIGCertStatus                certStatus;
  132.     unsigned long                certAttributeCount;
  133.     unsigned long                issuerAttributeCount;
  134.     Str255                        serialNumber;
  135. };
  136. #if defined(powerc) || defined(__powerc)
  137. #pragma options align=reset
  138. #endif
  139.  
  140. typedef struct SIGCertInfo SIGCertInfo;
  141.  
  142. typedef SIGCertInfo *SIGCertInfoPtr;
  143.  
  144. #if defined(powerc) || defined (__powerc)
  145. #pragma options align=mac68k
  146. #endif
  147. struct SIGSignerInfo {
  148.     unsigned long                signingTime;
  149.     unsigned long                certCount;
  150.     unsigned long                certSetStatusTime;
  151.     SIGSignatureStatus            signatureStatus;
  152. };
  153. #if defined(powerc) || defined(__powerc)
  154. #pragma options align=reset
  155. #endif
  156.  
  157. typedef struct SIGSignerInfo SIGSignerInfo;
  158.  
  159. typedef SIGSignerInfo *SIGSignerInfoPtr;
  160.  
  161. #if defined(powerc) || defined (__powerc)
  162. #pragma options align=mac68k
  163. #endif
  164. struct SIGNameAttributesInfo {
  165.     Boolean                        onNewLevel;
  166.     SIGNameAttributeType        attributeType;
  167.     ScriptCode                    attributeScript;
  168.     Str255                        attribute;
  169. };
  170. #if defined(powerc) || defined(__powerc)
  171. #pragma options align=reset
  172. #endif
  173.  
  174. typedef struct SIGNameAttributesInfo SIGNameAttributesInfo;
  175.  
  176. typedef SIGNameAttributesInfo *SIGNameAttributesInfoPtr;
  177.  
  178. typedef Ptr SIGContextPtr;
  179.  
  180. typedef Ptr SIGSignaturePtr;
  181.  
  182. /*
  183. Certificates are always in order. That is, the signers cert is always 0, the
  184. issuer of the signers cert is always 1 etc… to the number of certificates-1.
  185. You can use this constant for readability in your code.
  186. */
  187.  
  188. #define kSIGSignerCertIndex 0
  189.  
  190. /*
  191. Call back procedure supplied by developer, return false to cancel the current
  192. process.
  193. */
  194.  
  195. typedef pascal Boolean (*SIGStatusProcPtr)(void);
  196.  
  197. enum {
  198.     uppSIGStatusProcInfo = kPascalStackBased
  199.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  200. };
  201.  
  202. #if USESROUTINEDESCRIPTORS
  203. typedef UniversalProcPtr SIGStatusUPP;
  204.  
  205. #define CallSIGStatusProc(userRoutine)        \
  206.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIGStatusProcInfo)
  207. #define NewSIGStatusProc(userRoutine)        \
  208.         (SIGStatusUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIGStatusProcInfo, GetCurrentISA())
  209. #else
  210. typedef SIGStatusProcPtr SIGStatusUPP;
  211.  
  212. #define CallSIGStatusProc(userRoutine)        \
  213.         (*(userRoutine))()
  214. #define NewSIGStatusProc(userRoutine)        \
  215.         (SIGStatusUPP)(userRoutine)
  216. #endif
  217.  
  218. /*
  219. Resource id's of standard signature icon suite, all sizes and colors are available.
  220. */
  221.  
  222. #define kSIGSignatureIconResID -16800
  223.  
  224. #define kSIGValidSignatureIconResID -16799
  225.  
  226. #define kSIGInvalidSignatureIconResID -16798
  227.  
  228. /* ——————————————————————————————— CONTEXT CALLS ——————————————————————————————— */
  229. /*
  230. To use the Digital Signature toolbox you will need a SIGContextPtr.  To create
  231. a SIGContextPtr you simply call SIGNewContext and it will create and initialize
  232. a context for you.  To free the memory occupied by the context and invalidate
  233. its internal data, call SIGDisposeContext. An initialized context has no notion
  234. of the type of operation it will be performing however, once you call
  235. SIGSignPrepare SIGVerifyPrepare, or SIGDigestPrepare, the contexts operation
  236. type is set and to switch  to another type of operation will require creating a
  237. new context. Be sure to pass the same context to corresponding toolbox calls
  238. (ie SIGSignPrepare, SIGProcessData, SIGSign)  in other words mixing lets say
  239. signing and verify calls with the same context is not allowed.
  240. */
  241.  
  242. #ifdef __cplusplus
  243. extern "C" {
  244. #endif
  245.  
  246. extern pascal OSErr SIGNewContext(SIGContextPtr *context)
  247.  FOURWORDINLINE(0x203C, 2, 1900, 0xAA5D);
  248. extern pascal OSErr SIGDisposeContext(SIGContextPtr context)
  249.  FOURWORDINLINE(0x203C, 2, 1901, 0xAA5D);
  250. extern pascal OSErr SIGSignPrepare(SIGContextPtr context, const FSSpec *signerFile, ConstStr255Param prompt, Size *signatureSize)
  251.  FOURWORDINLINE(0x203C, 8, 1902, 0xAA5D);
  252. extern pascal OSErr SIGSign(SIGContextPtr context, SIGSignaturePtr signature, SIGStatusUPP statusProc)
  253.  FOURWORDINLINE(0x203C, 6, 1903, 0xAA5D);
  254. extern pascal OSErr SIGVerifyPrepare(SIGContextPtr context, SIGSignaturePtr signature, Size signatureSize, SIGStatusUPP statusProc)
  255.  FOURWORDINLINE(0x203C, 8, 1904, 0xAA5D);
  256. extern pascal OSErr SIGVerify(SIGContextPtr context)
  257.  FOURWORDINLINE(0x203C, 2, 1905, 0xAA5D);
  258. extern pascal OSErr SIGDigestPrepare(SIGContextPtr context)
  259.  FOURWORDINLINE(0x203C, 2, 1906, 0xAA5D);
  260. extern pascal OSErr SIGDigest(SIGContextPtr context, SIGDigestData digest)
  261.  FOURWORDINLINE(0x203C, 4, 1907, 0xAA5D);
  262. extern pascal OSErr SIGProcessData(SIGContextPtr context, const void *data, Size dataSize)
  263.  FOURWORDINLINE(0x203C, 6, 1908, 0xAA5D);
  264. extern pascal OSErr SIGShowSigner(SIGContextPtr context, ConstStr255Param prompt)
  265.  FOURWORDINLINE(0x203C, 4, 1909, 0xAA5D);
  266. extern pascal OSErr SIGGetSignerInfo(SIGContextPtr context, SIGSignerInfo *signerInfo)
  267.  FOURWORDINLINE(0x203C, 4, 1910, 0xAA5D);
  268. extern pascal OSErr SIGGetCertInfo(SIGContextPtr context, unsigned long certIndex, SIGCertInfo *certInfo)
  269.  FOURWORDINLINE(0x203C, 6, 1911, 0xAA5D);
  270. extern pascal OSErr SIGGetCertNameAttributes(SIGContextPtr context, unsigned long certIndex, unsigned long attributeIndex, SIGNameAttributesInfo *attributeInfo)
  271.  FOURWORDINLINE(0x203C, 8, 1912, 0xAA5D);
  272. extern pascal OSErr SIGGetCertIssuerNameAttributes(SIGContextPtr context, unsigned long certIndex, unsigned long attributeIndex, SIGNameAttributesInfo *attributeInfo)
  273.  FOURWORDINLINE(0x203C, 8, 1913, 0xAA5D);
  274. extern pascal OSErr SIGFileIsSigned(const FSSpec *fileSpec)
  275.  FOURWORDINLINE(0x203C, 2, 2500, 0xAA5D);
  276. extern pascal OSErr SIGSignFile(SIGContextPtr context, Size signatureSize, const FSSpec *fileSpec, SIGStatusUPP statusProc)
  277.  FOURWORDINLINE(0x203C, 8, 2501, 0xAA5D);
  278. extern pascal OSErr SIGVerifyFile(SIGContextPtr context, const FSSpec *fileSpec, SIGStatusUPP statusProc)
  279.  FOURWORDINLINE(0x203C, 6, 2502, 0xAA5D);
  280. #ifdef __cplusplus
  281. }
  282. #endif
  283.  
  284. #endif
  285.  
  286.